

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>用 Ansible 配置 iSCSI Target &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="用命令行配置 iSCSI Target" href="../iscsi-target-cli/" />
    <link rel="prev" title="iSCSI Targets" href="../iscsi-targets/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 块设备</a> &raquo;</li>
        
          <li><a href="../rbd-integrations/">Ceph 块设备与第三方对接</a> &raquo;</li>
        
          <li><a href="../iscsi-overview/">Ceph iSCSI Gateway</a> &raquo;</li>
        
          <li><a href="../iscsi-targets/">iSCSI Targets</a> &raquo;</li>
        
      <li>用 Ansible 配置 iSCSI Target</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/rbd/iscsi-target-ansible.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 块设备</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../rados-rbd-cmds/">基本命令</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-operations/">运维</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../rbd-integrations/">对接</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../rbd-ko/">内核模块</a></li>
<li class="toctree-l3"><a class="reference internal" href="../qemu-rbd/">QEMU</a></li>
<li class="toctree-l3"><a class="reference internal" href="../libvirt/">libvirt</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-kubernetes/">Kubernetes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-nomad/">Nomad</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-openstack/">OpenStack</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-cloudstack/">CloudStack</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../iscsi-overview/">LIO iSCSI Gateway</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../iscsi-requirements/">Requirements</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../iscsi-targets/">Configuring the iSCSI Target</a></li>
<li class="toctree-l4"><a class="reference internal" href="../iscsi-initiators/">Configuring the iSCSI Initiators</a></li>
<li class="toctree-l4"><a class="reference internal" href="../iscsi-monitoring/">Monitoring the iSCSI Gateways</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-windows/">Windows</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="ansible-iscsi-target">
<h1>用 Ansible 配置 iSCSI Target<a class="headerlink" href="#ansible-iscsi-target" title="Permalink to this headline">¶</a></h1>
<p>The Ceph iSCSI gateway is the iSCSI target node and also a Ceph client
node. The Ceph iSCSI gateway can be provisioned on dedicated node
or be colocated on a Ceph Object Store Disk (OSD) node. The following steps will
install and configure the Ceph iSCSI gateway for basic operation.</p>
<p><strong>Requirements:</strong></p>
<ul class="simple">
<li><p>A running Ceph Luminous (12.2.x) cluster or newer</p></li>
<li><p>Red Hat Enterprise Linux/CentOS 7.5 (or newer); Linux kernel v4.16 (or newer)</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">ceph-iscsi</span></code> package installed on all the iSCSI gateway nodes</p></li>
</ul>
<p><strong>Installation:</strong></p>
<ol class="arabic">
<li><p>On the Ansible installer node, which could be either the administration node
or a dedicated deployment node, perform the following steps:</p>
<ol class="arabic">
<li><p>As <code class="docutils literal notranslate"><span class="pre">root</span></code>, install the <code class="docutils literal notranslate"><span class="pre">ceph-ansible</span></code> package:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># yum install ceph-ansible</span>
</pre></div>
</div>
</li>
<li><p>Add an entry in <code class="docutils literal notranslate"><span class="pre">/etc/ansible/hosts</span></code> file for the gateway group:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">iscsigws</span><span class="p">]</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">igw</span><span class="o">-</span><span class="mi">1</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">igw</span><span class="o">-</span><span class="mi">2</span>
</pre></div>
</div>
</li>
</ol>
</li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If co-locating the iSCSI gateway with an OSD node, then add the OSD node to the
<code class="docutils literal notranslate"><span class="pre">[iscsigws]</span></code> section.</p>
</div>
<p><strong>Configuration:</strong></p>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-ansible</span></code> package places a file in the <code class="docutils literal notranslate"><span class="pre">/usr/share/ceph-ansible/group_vars/</span></code>
directory called <code class="docutils literal notranslate"><span class="pre">iscsigws.yml.sample</span></code>. Create a copy of this sample file named
<code class="docutils literal notranslate"><span class="pre">iscsigws.yml</span></code>. Review the following Ansible variables and descriptions,
and update accordingly. See the <code class="docutils literal notranslate"><span class="pre">iscsigws.yml.sample</span></code> for a full list of
advanced variables.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Variable</p></th>
<th class="head"><p>Meaning/Purpose</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">seed_monitor</span></code></p></td>
<td><p>Each gateway needs access to the
ceph cluster for rados and rbd
calls. This means the iSCSI gateway
must have an appropriate
<code class="docutils literal notranslate"><span class="pre">/etc/ceph/</span></code> directory defined.
The <code class="docutils literal notranslate"><span class="pre">seed_monitor</span></code> host is used to
populate the iSCSI gateway’s
<code class="docutils literal notranslate"><span class="pre">/etc/ceph/</span></code> directory.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">cluster_name</span></code></p></td>
<td><p>Define a custom storage cluster
name.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">gateway_keyring</span></code></p></td>
<td><p>Define a custom keyring name.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">deploy_settings</span></code></p></td>
<td><p>If set to <code class="docutils literal notranslate"><span class="pre">true</span></code>, then deploy the
settings when the playbook is ran.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">perform_system_checks</span></code></p></td>
<td><p>This is a boolean value that checks
for multipath and lvm configuration
settings on each gateway. It must be
set to true for at least the first
run to ensure multipathd and lvm are
configured properly.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">api_user</span></code></p></td>
<td><p>The user name for the API. The
default is <cite>admin</cite>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">api_password</span></code></p></td>
<td><p>The password for using the API. The
default is <cite>admin</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">api_port</span></code></p></td>
<td><p>The TCP port number for using the
API. The default is <cite>5000</cite>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">api_secure</span></code></p></td>
<td><p>True if TLS must be used. The
default is <cite>false</cite>. If true the user
must create the necessary
certificate and key files. See the
gwcli man file for details.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">trusted_ip_list</span></code></p></td>
<td><p>A list of IPv4 or IPv6 addresses
who have access to the API. By
default, only the iSCSI gateway
nodes have access.</p></td>
</tr>
</tbody>
</table>
<p><strong>Deployment:</strong></p>
<p>Perform the followint steps on the Ansible installer node.</p>
<ol class="arabic">
<li><p>As <code class="docutils literal notranslate"><span class="pre">root</span></code>, execute the Ansible playbook:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1"><span class="nb">cd</span> /usr/share/ceph-ansible</span>
<span class="prompt1">ansible-playbook site.yml --limit iscsigws</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>The Ansible playbook will handle RPM dependencies, setting up daemons,
and installing gwcli so it can be used to create iSCSI targets and export
RBD images as LUNs. In past versions, <code class="docutils literal notranslate"><span class="pre">iscsigws.yml</span></code> could define the
iSCSI target and other objects like clients, images and LUNs, but this is
no longer supported.</p>
</div>
</li>
<li><p>Verify the configuration from an iSCSI gateway node:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">gwcli ls</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>See the <a class="reference external" href="../iscsi-target-cli">Configuring the iSCSI Target using the Command Line Interface</a>
section to create gateways, LUNs, and clients using the <cite>gwcli</cite> tool.</p>
</div>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>Attempting to use the <code class="docutils literal notranslate"><span class="pre">targetcli</span></code> tool to change the configuration will
cause problems including ALUA misconfiguration and path failover
issues. There is the potential to corrupt data, to have mismatched
configuration across iSCSI gateways, and to have mismatched WWN information,
leading to client multipath problems.</p>
</div>
</li>
</ol>
<p><strong>Service Management:</strong></p>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-iscsi</span></code> package installs the configuration management
logic and a Systemd service called <code class="docutils literal notranslate"><span class="pre">rbd-target-api</span></code>. When the Systemd
service is enabled, the <code class="docutils literal notranslate"><span class="pre">rbd-target-api</span></code> will start at boot time and
will restore the Linux IO state. The Ansible playbook disables the
target service during the deployment. Below are the outcomes of when
interacting with the <code class="docutils literal notranslate"><span class="pre">rbd-target-api</span></code> Systemd service.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">systemctl &lt;start<span class="p">|</span>stop<span class="p">|</span>restart<span class="p">|</span>reload&gt; rbd-target-api</span>
</pre></div></div><ul>
<li><p><code class="docutils literal notranslate"><span class="pre">reload</span></code></p>
<p>A reload request will force <code class="docutils literal notranslate"><span class="pre">rbd-target-api</span></code> to reread the
configuration and apply it to the current running environment. This
is normally not required, since changes are deployed in parallel from
Ansible to all iSCSI gateway nodes</p>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">stop</span></code></p>
<p>A stop request will close the gateway’s portal interfaces, dropping
connections to clients and wipe the current LIO configuration from
the kernel. This returns the iSCSI gateway to a clean state. When
clients are disconnected, active I/O is rescheduled to the other
iSCSI gateways by the client side multipathing layer.</p>
</li>
</ul>
<p><strong>Removing the Configuration:</strong></p>
<p>The <code class="docutils literal notranslate"><span class="pre">ceph-ansible</span></code> package provides an Ansible playbook to
remove the iSCSI gateway configuration and related RBD images. The
Ansible playbook is <code class="docutils literal notranslate"><span class="pre">/usr/share/ceph-ansible/purge_gateways.yml</span></code>. When
this Ansible playbook is ran a prompted for the type of purge to
perform:</p>
<p><em>lio</em> :</p>
<p>In this mode the LIO configuration is purged on all iSCSI gateways that
are defined. Disks that were created are left untouched within the Ceph
storage cluster.</p>
<p><em>all</em> :</p>
<p>When <code class="docutils literal notranslate"><span class="pre">all</span></code> is chosen, the LIO configuration is removed together with
<strong>all</strong> RBD images that were defined within the iSCSI gateway
environment, other unrelated RBD images will not be removed. Ensure the
correct mode is chosen, this operation will delete data.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>A purge operation is destructive action against your iSCSI gateway
environment.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>A purge operation will fail, if RBD images have snapshots or clones
and are exported through the Ceph iSCSI gateway.</p>
</div>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">[root@rh7-iscsi-client ceph-ansible]# </span>ansible-playbook purge_gateways.yml
<span class="go">Which configuration elements should be purged? (all, lio or abort) [abort]: all</span>


<span class="go">PLAY [Confirm removal of the iSCSI gateway configuration] *********************</span>


<span class="go">GATHERING FACTS ***************************************************************</span>
<span class="go">ok: [localhost]</span>


<span class="go">TASK: [Exit playbook if user aborted the purge] *******************************</span>
<span class="go">skipping: [localhost]</span>


<span class="go">TASK: [set_fact ] *************************************************************</span>
<span class="go">ok: [localhost]</span>


<span class="go">PLAY [Removing the gateway configuration] *************************************</span>


<span class="go">GATHERING FACTS ***************************************************************</span>
<span class="go">ok: [ceph-igw-1]</span>
<span class="go">ok: [ceph-igw-2]</span>


<span class="go">TASK: [igw_purge | purging the gateway configuration] *************************</span>
<span class="go">changed: [ceph-igw-1]</span>
<span class="go">changed: [ceph-igw-2]</span>


<span class="go">TASK: [igw_purge | deleting configured rbd devices] ***************************</span>
<span class="go">changed: [ceph-igw-1]</span>
<span class="go">changed: [ceph-igw-2]</span>


<span class="go">PLAY RECAP ********************************************************************</span>
<span class="go">ceph-igw-1                 : ok=3    changed=2    unreachable=0    failed=0</span>
<span class="go">ceph-igw-2                 : ok=3    changed=2    unreachable=0    failed=0</span>
<span class="go">localhost                  : ok=2    changed=0    unreachable=0    failed=0</span>
</pre></div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../iscsi-target-cli/" class="btn btn-neutral float-right" title="用命令行配置 iSCSI Target" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../iscsi-targets/" class="btn btn-neutral float-left" title="iSCSI Targets" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>